/**
 * @param {number[]} encoded
 * @param {number} first
 * @return {number[]}
*/
var decode = function(encoded, first) {
  let result = new Array(encoded.length + 1);
  result[0] = first
  for(let i = 1; i < result.length; i++) {
    result[i] = encoded[i - 1] ^ result[i - 1];
  }
  return result;
};
let encoded = [1,2,3], first = 1;
console.log(decode(encoded, first));
encoded = [6,2,7,3], first = 4;
console.log(decode(encoded, first));
